#include <bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
struct node{
	int d,v,a;
};
node a[100005];
int p[100005];
bool fans[1005],f[1005][1005];
set<int>s1,s2;
int ans;
bool check(){
	s2.clear();
	for(int i=1;i<=m;i++){
		if(fans[i]!=0)continue;
		for(int j=1;j<=n;j++){
			if(f[i][j])s2.insert(j);
		}
	}
	if(s1.size()==s2.size())return 1;
	return 0;
}
void dfs(int dep,int sum){
	if(dep>m){
		if(check()){
			ans=max(ans,sum);
		}
		return ;
	}
	fans[dep]=1;
	dfs(dep+1,sum+1);
	fans[dep]=0;
	dfs(dep+1,sum);
}
void work(){
	bool fa=1,fb=1,fc=1;
	cin>>n>>m>>L>>V;
	for(int i=1;i<=n;i++){
		cin>>a[i].d>>a[i].v>>a[i].a;
		if(a[i].a!=0)fa=0;
		if(a[i].a<=0)fb=0;
		if(a[i].a>=0)fc=0;
	}
	for(int i=1;i<=m;i++)cin>>p[i];
	sort(p+1,p+m+1);
	int cnt=0;
	if(fa==1){
		for(int i=1;i<=n;i++){
			if(a[i].d<=p[m]){
				if(a[i].v>V)cnt++;	
			}
		}
		cout<<cnt<<" ";
		if(cnt)cout<<m-1;
		else cout<<m;
		cout<<'\n';
		return ;
	}
	if(fb==1){
		for(int i=1;i<=n;i++){
			if(a[i].d<=p[m]){
				double x=sqrt((p[m]-a[i].d)*2*a[i].a+a[i].v*a[i].v);
				if(x>V)cnt++;
			}
		}
		cout<<cnt<<" ";
		if(cnt)cout<<m-1;
		else cout<<m;
		cout<<'\n';
		return ;
	}
	memset(fans,0,sizeof(fans));
	memset(f,0,sizeof(f));
	s1.clear();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i].d<=p[j]){
				int w=(p[j]-a[i].d)*2*a[i].a+a[i].v*a[i].v;
				//if(i==4)cout<<j<<" "<<w<<' ';
				if(w<0)break ;
				double x=sqrt(w);
				if(x>V){
					//if(i==4)cout<<j<<" ";
					f[j][i]=1;
					s1.insert(i);
				}
			}
		}
	}
	cout<<s1.size();
	ans=0;
	dfs(1,0);
	cout<<" "<<ans<<'\n';
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	while(T--){
		work();
	}
	return 0;
}
